package com.wydstation.power.common;

import com.power.wydstation.AbstractDeviceFactory;
import com.power.wydstation.DeviceFactory;
import com.power.wydstation.DeviceInfo;
import com.wydstation.power.common.entity.station.*;
import com.wydstation.power.common.mapper.station.*;
import com.wydstation.power.common.service.StationInfoService;
import com.wydstation.power.common.utils.SpringTool;

public final class StationInfoContext {


    public StationInfo getStationInfoDetail(Integer id) {
        StationInfoMapper stationInfoMapper = (StationInfoMapper) SpringTool.getBean("stationInfoMapper");
        StationInfo stationInfo = stationInfoMapper.selectById(id);
        return stationInfo;
    }

    public int insertStation(StationInfo stationInfo, StationClassify stationClassify, StationCollection collection,
                             StationGrid stationGrid, StationOther stationOther, StationSpeedAttr stationSpeedAttr) {
        StationInfoMapper stationInfoMapper = (StationInfoMapper) SpringTool.getBean("stationInfoMapper");
        int s = stationInfoMapper.insert(stationInfo);
        StationSpeedAttrMapper stationSpeedAttrMapper = (StationSpeedAttrMapper) SpringTool.getBean("stationSpeedAttrMapper");
        stationSpeedAttrMapper.insert(stationSpeedAttr);
        StationGridMapper stationGridMapper = (StationGridMapper) SpringTool.getBean("stationGridMapper");
        stationGridMapper.insert(stationGrid);
        StationClassifyMapper stationClassifyMapper = (StationClassifyMapper) SpringTool.getBean("stationClassifyMapper");
        stationClassifyMapper.insert(stationClassify);
        StationCollectionMapper stationCollectionMapper = (StationCollectionMapper) SpringTool.getBean("stationCollectionMapper");
        stationCollectionMapper.insert(collection);
        StationOtherMapper stationOtherMapper = (StationOtherMapper) SpringTool.getBean("stationOtherMapper");
        stationOtherMapper.insert(stationOther);
        stationCollectionMapper.insert(collection);
        return 1;
    }

    public int updateStation(StationInfo stationInfo, StationClassify stationClassify, StationCollection collection,
                             StationGrid stationGrid, StationOther stationOther, StationSpeedAttr stationSpeedAttr) {
        StationInfoMapper stationInfoMapper = (StationInfoMapper) SpringTool.getBean("stationInfoMapper");
        stationInfoMapper.insert(stationInfo);
        StationSpeedAttrMapper stationSpeedAttrMapper = (StationSpeedAttrMapper) SpringTool.getBean("stationSpeedAttrMapper");
        stationSpeedAttrMapper.update(stationSpeedAttr,null);
        StationGridMapper stationGridMapper = (StationGridMapper) SpringTool.getBean("stationGridMapper");
        stationGridMapper.update(stationGrid,null);
        StationClassifyMapper stationClassifyMapper = (StationClassifyMapper) SpringTool.getBean("stationClassifyMapper");
        stationClassifyMapper.update(stationClassify,null);
        StationCollectionMapper stationCollectionMapper = (StationCollectionMapper) SpringTool.getBean("stationCollectionMapper");
        stationCollectionMapper.update(collection,null);
        StationOtherMapper stationOtherMapper = (StationOtherMapper) SpringTool.getBean("stationOtherMapper");
        stationOtherMapper.update(stationOther,null);
        stationCollectionMapper.update(collection,null);
        return 1;
    }

    public static void main(String[] args) {
        AbstractDeviceFactory factory=new DeviceFactory();
        DeviceInfo deviceInfo = factory.create();
    }


}
